package com.yunji;

import com.yunji.common.utils.bean.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji
 * @Title: MallApplication
 * @Description: 商城启动类
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-03-29 16:27:13      V1.0        HuaAo       新建类
 */
@EnableAsync
@EnableScheduling
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class CoffeeApplication {
    private static final Logger logs = LoggerFactory.getLogger(CoffeeApplication.class);

    public static void main(String[] args) throws UnknownHostException {
        //System.setProperty("spring.security.strategy", SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
        ConfigurableApplicationContext application = SpringApplication.run(CoffeeApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = BeanUtils.getString(env.getProperty("server.servlet.context-path"));
        String build = "\n----------------------------------------------------------\n\t" +
                "Application YUNJI Mall is running! Access URLs:\n\t" +
                "Native APIs: http://localhost:{}{} \n\t" +
                "Remote APIs: http://{}:{}{} \n\t" +
                "Knife4j文档 : http://{}:{}{}doc.html \n" +
                "----------------------------------------------------------\n";
        logs.info(build, port, path, ip, port, path, ip, port, path);
    }
}
